#!/usr/bin/python

_SCM_ID = "$Id$"
_Revision = "$Revision$"
_SVN_URL = "$URL$"

ReleaseNo = '0.0'

import os

__all__ = [
  'ReleaseNo',
  'ReleaseInfo',
]

class ReleaseInfo:
    def __init__(self):
        global ReleaseNo, _SVN_URL, _Revision
        url = _SVN_URL.replace('$', '').replace('URL: ', '')
        rev = _Revision.replace('$', '').replace('Revision: ', '')
        comp = ''
        while True:
            try:
                p = url.rindex('/')
            except ValueError:
                break
            else:
                base, comp = url[:p], url[p+1:]
                if base.endswith('/trunk'):
                    url = base
                    comp = 'trunk'
                    break
                elif base.endswith('/branches') or base.endswith('/tags'):
                    break
            url = base
        self.url = url
        self.rev = rev
        self.rel = ReleaseNo
        self.versid = os.environ['CURRENT_VERSION_ID']
        self.tag = comp

